#ifdef __APPLE__
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
#include <OpenGL/freeglut.h> // This line might not work - comment it out with // if so
#else
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <GL/freeglut.h>
#endif
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <sstream>
#include <time.h>
#include "jeplayer.h"
#include "jecircle.h"

using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using std::vector;
using std::string;
using std::istringstream;
using std::ostringstream;
using std::stringstream;

// METHOD DECLARATIONS (In order of appearance)

void resetGame();
void setPixel(GLint, GLint, CirclePt);
void circlePlotPoints(CirclePt, CirclePt);
void circleMidpoint(CirclePt, GLint);
void init();
void drawStar();
void displayFcn();
void winReshapeFcn(int, int);
void moveStar();
void arenaWrap();
bool starInCircle(int i);
void endGameTest(int);
void displayScore();
void displayText(string, int, int);
void incrementScore();
void setCombo();
void unsetCombo();
void displayCombo();
void dotOverlap(int);
void drawDots();
void manageDots();
void addNewDot();
void addNewDot(int);
void difficultyMod();
void posChange();
void showFPS();
void pauseUnpause();
void keyDown(unsigned char, int, int);
void keyUp(unsigned char, int, int);
void spKeyDown(int, int, int);
void spKeyUp(int, int, int);
void mouseMove();
int main(int, char**);

// DECLARATIONS AND INITIALISATIONS

string hello = "Welcome to Just Evasion. \nIn this game you control the eight-pointed star. \nYou must not let the circles enclose you. \nYou do not have any weapons. \nYour only defence is to force the circles, which are quite stupid, to overlap each other. \nWhen two circles overlap, one dies and a new one appears. \nIf you are careful, you can last a very long time before being killed. \n\nMove with WASD or the arrow keys. Pause with P. Quit with Esc.";
GLsizei winWidth = 600, winHeight = 600;    // Initial display window size.
vector< CirclePt > dots;
PlayerStar star;
bool paused = true;
bool* keys = new bool[256];
bool* spKeys = new bool[256];
int difficulty;
int dotSpawn  = -1;
int score = 0;
stringstream scoreStream;
string scoreString = "Score: 0 \0";
bool isComboHit = false; // Keeps track of combo
int comboNum = 1; // Keeps track of how many dots you've overlapped in one execution of manageDots()
int killed = 0;
int level = 10; // How accurate the star-in-circle hit detection is. 0 = invincible, 1 = centre on centre, 20 = edge on edge. Lower is easier.
float rMod = 0.1f;
float gMod = 0.25f;
float bMod = 0.3f;
bool comboDisplay = false;
string comboString = "COMBO! x";
int comboFade = 0;
int lastCombo = 0;
int frame = 0;
char* title;
int currentTime = 0;
int timeBase = 0;


